/*
* Copyright 2018 Shanxi Lu'an Taihang Laihui Net Tech co.,LTD.
*/
package com.laihuichuxing.wyc.dao;


import com.jarvis.cache.annotation.Cache;
import com.jarvis.cache.annotation.CacheDelete;
import com.jarvis.cache.annotation.CacheDeleteKey;
import com.laihuichuxing.order.wy.entity.WyOrderEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * Description:
 *
 * @author: Qinxuefeng
 * @since: 1.0
 * Create Date Time: 2018/11/19 17:43
 * Update Date Time:
 */
public interface WyOrderDao {

    /**
     * Description: 新增订单
     * @param  wyOrderEntity 网约车订单实体类
     * @return Integer
     * @author YangGuang
     * Create Date Time: 2018/11/19 16:24
     * Update Date Time:
     */
    @CacheDelete({ @CacheDeleteKey(value = "'wy_order-byorderno-' + #args[0].orderNo") })
    Integer insert(WyOrderEntity wyOrderEntity);

    /**
     * Description: 删除订单
     * @param map 需要删除的key,value
     * @return Integer
     * @author YangGuang
     * Create Date Time: 2018/11/19 16:25
     * Update Date Time:
     */
    Integer delete(Map<String,Object> map);
    /**
     * Description: 查询取消订单
     * @param  wyOrderEntity
     * @return
     * @author QinXueFeng
     * Create Date Time: 2018/11/19 17:24
     * Update Date Time:
     */
    WyOrderEntity findCancalOrder(WyOrderEntity wyOrderEntity);
    /**
     * Description: 根据乘客ID查询未完成行程
     * @param  passengerId
     * @return WyOrderEntity
     * @author QinXueFeng
     * Create Date Time: 2018/11/19 17:26
     * Update Date Time:
     */
    @Cache(expire = 3600, expireExpression = "null == #retVal ? 600:3600",key="'wy_order-bypassengerid-' + #args[0]")
    WyOrderEntity findOrderByPassengerId(String passengerId);
    /**
     * Description: 存在未完成的訂單
     * @param  wyOrderEntity
     * @return WyOrderEntity
     * @author QinXueFeng
     * Create Date Time: 2018/11/19 17:26
     * Update Date Time:
     */
    WyOrderEntity  findOrderLtState(WyOrderEntity wyOrderEntity);
    /**
     * Description: 存在完成的訂單
     * @param  wyOrderEntity
     * @return WyOrderEntity
     * @author QinXueFeng
     * Create Date Time: 2018/11/19 17:26
     * Update Date Time:
     */
    WyOrderEntity  findOrderGtState(WyOrderEntity wyOrderEntity);

    /**
     * Description: 根据乘客ID查询未完成行程分页
     * @param  passengerId 乘客id
     * @param  orderStatus 状态
     * @param  page
     * @param  size
     * @return WyOrderEntity
     * @author QinXueFeng
     * Create Date Time: 2018/11/19 17:26
     * Update Date Time:
     */
    List<WyOrderEntity> findPageByPassengerId(@Param("passengerId")String passengerId, @Param("orderStatus") String orderStatus
            , @Param("page")Integer page, @Param("size") Integer size);
    /**
     * Description: 查询司机信息
     * @param  wyOrderEntity
     * @return WyOrderEntity
     * @author QinXueFeng
     * Create Date Time: 2018/11/19 17:26
     * Update Date Time:
     */
    Map<String,Object> findDriverInfo(WyOrderEntity wyOrderEntity);
    /**
     * Description: 查询当日取消条数
     * @param  userId 用户Id
     * @return  Integer
     * @author QinXueFeng
     * Create Date Time: 2018/11/20 10:27
     * Update Date Time:
     */
    @Cache(expire = 1200, expireExpression = "null == #retVal ? 120: 1200",key="'wy_order_cancle_log-' + #args[0]")
    Integer findCancaleNum(@Param("userId") String userId);
    /**
     * Description: 修改订单状态
     * @param  wyOrderEntity
     * @return  Integer
     * @author QinXueFeng
     * Create Date Time: 2018/11/20 10:29
     * Update Date Time:
     */
    Integer updateByPrimaryKeySelective(WyOrderEntity wyOrderEntity);
    /**
     * Description: 查询曹操订单
     * @param  orderNo 我方订单号
     * @return  String 曹操订单号
     * @author QinXueFeng
     * Create Date Time: 2018/11/20 10:31
     * Update Date Time:
     */
    @Cache(expire = 3600,expireExpression = "null == #retVal ? 600:3600",key="'wy_order-byorderno-' + #args[0]")
    String getCaocaoOrderNo(String orderNo);
    /**
     * Description: 查询订单
     * @param  orderNo
     * @return  WyOrderEntity
     * @author QinXueFeng
     * Create Date Time: 2018/11/20 11:33
     * Update Date Time:
     */
    @Cache(expire = 3600, expireExpression = "null == #retVal ? 600: 3600", key = "'wy_order-byorderno-' + #args[0]")
    WyOrderEntity findOrderById(String orderNo);
    /** 
     * Description: 新增取消记录
     * @param  userId
     * @return  Integer
     * @author QinXueFeng
     * Create Date Time: 2018/11/20 15:02
     * Update Date Time:
     */
    @CacheDelete({ @CacheDeleteKey(value = "'wy_order_cancle_log-' + #args[0]") })
    Integer insertCancalLog(@Param("userId") String userId);
    /** 
     * Description: 修改订单
     * @param  wyOrderEntity
     * @return  Integer
     * @author QinXueFeng
     * Create Date Time: 2018/11/20 15:53
     * Update Date Time:
     */
    @CacheDelete({ @CacheDeleteKey(value = "'wy_order-byorderno-' + #args[0].orderNo", condition = "#retVal > 0") })
    Integer update(WyOrderEntity wyOrderEntity);
    /**
     * Description:  修改订单信息
     * @param  wyOrderEntity
     * @return
     * @author QinXueFeng
     * Create Date Time: 2018/11/27 14:12
     * Update Date Time:
     */
    @CacheDelete({ @CacheDeleteKey(value = "'wy_order-byorderno-' + #args[0].orderNo", condition = "#retVal > 0") })
    Integer saveOrderPayTable(WyOrderEntity wyOrderEntity);
    /**
     * Description: 更新订单信息
     * @param  wyOrderEntity
     * @return
     * @author QinXueFeng
     * Create Date Time: 2018/11/27 16:34
     * Update Date Time:
     */
    @CacheDelete({@CacheDeleteKey(value = "'wy_order-byorderno-' + #args[0].orderNo",condition = "#retVal > 0")})
    Integer updateOrderPayTable(WyOrderEntity wyOrderEntity);

    /**
     * Description: 查询乘客订单编号
     * @param passengerPhone 乘客手机号
     * @return 订单编号
     * @author: YangGuang
     * Create Date Time: 2018/10/12 11:56
     * Update Date Time:
     */
    @Cache(expire = 3600,expireExpression = "null == #retVal ? 600:3600",key = "'orderno-bypassphoneandstatus-' + #args[0] + #args[1]")
    String selectPassengerOrderId(@Param("passengerPhone") String passengerPhone, @Param("orderStatus") int orderStatus);

    /**
     * Description: 查询乘客手机号
     * @param mobile 司机手机号
     * @return 乘客手机号
     * @author: YangGuang
     * Create Date Time: 2018/10/16 17:01
     * Update Date Time:
     */
    @Cache(expire = 3600,expireExpression = "null == #retVal ? 600:3600",key = "'passengerphone-bydriverphone-' + #args[0] + #args[1]")
    String selectPassengerMobile(@Param("mobile") String mobile, @Param("orderStatus") int orderStatus);

    /**
     * Description: 根据订单id查询手机号
     * @param orderNo 订单id
     * @return 乘客手机号
     * @author: YangGuang
     * Create Date Time: 2018/10/18 10:13
     * Update Date Time:
     */
    @Cache(expire = 3600,expireExpression = "null == #retVal ? 600:3600",key = "'passengerphone-byorderno-' + #args[0]")
    String selectMobileByOrderId(String orderNo);
    /**
     * Description: 查询订单
     * @param passengerPhone 乘客手机号
     * @return 订单编号
     * @author: YangGuang
     * Create Date Time: 2018/10/12 11:56
     * Update Date Time:
     */
    @Cache(expire = 3600,expireExpression = "null == #retVal ? 600:3600",key = "'wy_order-bypassphoneandstatus-' + #args[0] + args[1]")
    Map<String,Object> selectOrder(@Param("passengerPhone") String passengerPhone, @Param("orderStatus") int orderStatus);

    /**
     * Description: 修改订单表，司机Id，订单状态
     * @param  orderNo 订单编号
     * @param  driverId 订单编号
     * Author: Qinxuefeng
     * Version: 1.0
     * Create Date Time: 2018/10/16 9:25.
     * Update Date Time:
     */
    @CacheDelete({ @CacheDeleteKey(value = "'wy_order-byorderno-' + #args[0]", condition = "#retVal > 0") })
    int updateWyOrder(@Param("orderNo") String orderNo, @Param("driverId") String driverId);
    /**
     * Description: 修改约车标识
     * @param  orderNo 订单编号
     * @param  caoOrderNo caocao订单编号
     * @param  i 约车标识
     * @author QinXueFeng
     * Create Date Time: 2018/11/15 14:21
     * Update Date Time:
     */
    @CacheDelete({ @CacheDeleteKey(value = "'wy_order-byorderno-' + #args[1]", condition = "#retVal > 0") })
    void updateFlage(@Param("caoOrderNo")String caoOrderNo,@Param("orderNo")String orderNo, @Param("flag")int i);
    /** 
     * Description: 查看司机id
     * @param  driverPhone
     * @return  
     * @author QinXueFeng
     * Create Date Time: 2018/12/10 18:02
     * Update Date Time:
     */ 
    @Cache(expire = 3600,expireExpression = "null == #retVal ? 600:3600",key = "'wy_driver-bydriverid-' + #args[0]")
    String selectDriverId(@Param("driverPhone")String driverPhone);
    /** 
     * Description: 修改司机状态
     * @param  phone
     * @return  
     * @author QinXueFeng
     * Create Date Time: 2018/12/10 18:06
     * Update Date Time:
     */ 
    void updateWyDriver(@Param("phone") String phone);
}
